In computer science, caches are used to reduce the number of accesses to main memory and to reduce the latency associated with data retrieval. Essentially, a cache is smaller and faster than main memory and can be used to store copies of frequently accessed data.
In computer graphics, a cache can be situated between a framebuffer and a graphics pipeline (e.g., a rasterizer). The cache allows the rasterizer to access pixel data at higher speed, assuming the needed pixel data is in the cache.
Typically, 24 bits (three bytes) of data are associated with each pixel—for example, 24 bits of color data (e.g., three eight-bit color values, one value for red, one for green and one for blue) may be associated with a pixel. Each cache line is typically 256 bits (32 bytes) in length. Because 256 is not a whole number multiple of 24 (256/24=10⅔), storing 24-bit pixels in a cache can be problematic.
For example, all of the data for ten 24-bit pixels and two-thirds of the data for an eleventh 24-bit pixel can be stored in one cache line, with the remainder of the data for the eleventh pixel stored in a second cache line. However, this can be problematic because two memory accesses instead of one are required in order to read the data for the eleventh pixel.
Alternatively, a 24-bit pixel can be stored every 32 bits (four bytes). That is, eight empty bit locations separate each 24-bit pixel from the next. Consequently, each 256-bit cache line contains data for only eight 24-bit pixels. This avoids the problem described above, but as a result 25 percent of the space available in a cache line is unused.